<template>
  <section>
    <el-row>
      <el-col :span="24" class="toobar-form-left-panel">
        <el-form :inline="true">
          <el-form-item>
            <el-input
              :placeholder="keyworldPlaceholder"
              v-model="toobarForm.keyworld"
              size="mini"
            >
              <template slot="append">
                <el-button
                  slot="append"
                  icon="el-icon-search"
                  @click="onSearch(1)"
                ></el-button>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item v-show="multiConditionQuery">
            <el-button
              icon="el-icon-search"
              type="primary"
              @click="dialogVisible = true"
              size="mini"
              >多条件查询</el-button
            >
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-plus"
              @click="onAdd"
              size="mini"
              >新增</el-button
            >
          </el-form-item>
          <el-form-item>
            <el-button
              size="mini"
              type="danger"
              :disabled="selectionRows.length == 0"
              @click="onBatchDelete"
              >批量删除</el-button
            >
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
    <el-dialog title="多条件查询" :visible.sync="dialogVisible"> </el-dialog>
  </section>
</template>
<script>
export default {
  name: "Toolbar",
  props: {
    keyworldPlaceholder: {
      type: String,
      default: "请输入关键字",
    },
    getData: {
      type: Function,
      default: null,
    },
    add: {
      type: Function,
      default: null,
    },
    multiConditionQuery: {
      type: Boolean,
      default: false,
    },
    selectionRows: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  data() {
    return {
      toobarForm: {
        keyworld: "",
      },
      dialogVisible: false,
    };
  },
  methods: {
    onSearch(type) {
      if (this.getData != null) {
        if (type == 1) {
          this.getData({ keyworld: this.toobarForm.keyworld });
        } else {
        }
      }
    },
    onAdd() {
      if (this.add != null) {
        this.add();
      }
    },
    onBatchDelete() {},
  },
};
</script>
<style>
</style>